package com.trkj.base.newwork;

import android.content.Context;

import com.trkj.base.OnResponseResultListener;
import com.trkj.widget.view.PrettyProgressDialog;

/**
 * Created by LiZanhong on 2015/06/21.
 */
public class ProgressBarDataFromRemote extends WaitingDataFromRemote{
    private PrettyProgressDialog progressDialog;

    public ProgressBarDataFromRemote(Context context) {
        super(context);
    }

    public ProgressBarDataFromRemote(Context context, OnResponseResultListener responseResultListener) {
        super(context, responseResultListener);
    }

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        startProgressDialog();
    }

    protected void startProgressDialog(){
        if(progressDialog == null) {
            progressDialog = PrettyProgressDialog.createDialog(getContext());
        }
        progressDialog.setMessage("正在读取数据，请稍候……");
        progressDialog.show();
    }

    protected void closeProgressDialog(){
        if(progressDialog != null) {
            progressDialog.dismiss();
            progressDialog = null;
        }
    }

    @Override
    protected void onPostExecute(String s) {
        super.onPostExecute(s);
        closeProgressDialog();
    }

    @Override
    protected void onCancelled() {
        super.onCancelled();
        closeProgressDialog();
    }
}
